package admin

import (
	"APT/internal/model/input/input_basics"
	"APT/internal/service"
	"context"

	"APT/api/admin/pms"
)

func (c *ControllerPms) CouponTypeList(ctx context.Context, req *pms.CouponTypeListReq) (res *pms.CouponTypeListRes, err error) {
	list, totalCount, err := service.BasicsCouponType().List(ctx, &req.PmsCouponTypeListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*input_basics.PmsCouponTypeListModel{}
	}

	res = new(pms.CouponTypeListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}
func (c *ControllerPms) CouponTypeAllList(ctx context.Context, req *pms.CouponTypeAllListReq) (res *pms.CouponTypeAllListRes, err error) {
	list, err := service.BasicsCouponType().All(ctx, &req.PmsCouponTypeListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*input_basics.PmsCouponTypeAllListModel{}
	}

	res = new(pms.CouponTypeAllListRes)
	res.List = list
	return
}
func (c *ControllerPms) CouponTypeView(ctx context.Context, req *pms.CouponTypeViewReq) (res *pms.CouponTypeViewRes, err error) {
	data, err := service.BasicsCouponType().View(ctx, &req.PmsCouponTypeViewInp)
	if err != nil {
		return
	}

	res = new(pms.CouponTypeViewRes)
	res.PmsCouponTypeViewModel = data
	return
}
func (c *ControllerPms) CouponTypeEdit(ctx context.Context, req *pms.CouponTypeEditReq) (res *pms.CouponTypeEditRes, err error) {
	err = service.BasicsCouponType().Edit(ctx, &req.PmsCouponTypeEditInp)
	return
}
func (c *ControllerPms) CouponTypeDelete(ctx context.Context, req *pms.CouponTypeDeleteReq) (res *pms.CouponTypeDeleteRes, err error) {
	err = service.BasicsCouponType().Delete(ctx, &req.PmsCouponTypeDeleteInp)
	return
}
func (c *ControllerPms) CouponTypeMaxSort(ctx context.Context, req *pms.CouponTypeMaxSortReq) (res *pms.CouponTypeMaxSortRes, err error) {
	data, err := service.BasicsCouponType().MaxSort(ctx, &req.PmsCouponTypeMaxSortInp)
	if err != nil {
		return
	}

	res = new(pms.CouponTypeMaxSortRes)
	res.PmsCouponTypeMaxSortModel = data
	return
}
func (c *ControllerPms) CouponTypeStatus(ctx context.Context, req *pms.CouponTypeStatusReq) (res *pms.CouponTypeStatusRes, err error) {
	err = service.BasicsCouponType().Status(ctx, &req.PmsCouponTypeStatusInp)
	return
}
func (c *ControllerPms) SendMemberCoupon(ctx context.Context, req *pms.SendMemberCouponReq) (res *pms.SendMemberCouponRes, err error) {
	// source 来源：1-自主领取 2-系统发放 3-注册奖励 4-邀请奖励
	err = service.BasicsCouponType().SendMemberCoupon(ctx, &req.PmsSendMemberCouponInp, 2)
	return
}
